import scrapy


class GetGithubSpider(scrapy.Spider):

    name = 'get-Github'

    @property
    def start_urls(self):
        url_tmpl = 'https://github.com/shiyanlou?page={}&tab=repositories'
        return (url_tmpl.format(i) for i in range(1, 5))

    def parse(self, response):
        for course in response.css('div#user-repositories-list ul'):
            yield {
                'name': course.css('h3 font font::text').re_first('[^\d]*(\d+)[^\d]*'),
                'update_time': course.xpath('.//relative-time/@datetime').extract_first()
            }